#ifndef _TASKQUEUE_H
#define _TASKQUEUE_H
#include "MyTask.h"
#include <deque>
#include <queue>
#include <functional>
#include <mutex>
#include <condition_variable>

using std::deque;
using std::function;
using std::mutex;
using std::condition_variable;
using std::unique_lock;

using ElemType = function<void()>;

class TaskQueue {
public: 
    TaskQueue(size_t queSize);
    void push(ElemType & value);
    ElemType pop();
    bool full();
    bool empty();
    void wakeup();
    ~TaskQueue();
private:
    size_t _queSize;
    deque<ElemType> _que;
    mutex _mutex;
    condition_variable _notFull;
    condition_variable _notEmpty;
    bool _flag; //当_flag为ture时，标识的是线程池本身的唤醒操作
    //，当为false时，标识的是线程池退出之前进行的唤醒全部子线程的操作
};

#endif //_TASKQUEUE_H
